package c.e.a.c.l;

import android.content.Context;
import android.os.Build.VERSION;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView.LayoutParams;
import androidx.recyclerview.widget.RecyclerView.e;
import androidx.recyclerview.widget.RecyclerView.z;
import b.i.k.r;
import c.e.a.c.l.d.f;
import com.google.android.material.datepicker.CalendarConstraints;
import com.google.android.material.datepicker.DateSelector;
import com.google.android.material.datepicker.MaterialCalendarGridView;
import com.google.android.material.datepicker.Month;
import java.util.WeakHashMap;

/* compiled from: MonthsPagerAdapter */
public class o extends e<a> {
    public final CalendarConstraints c;
    public final DateSelector<?> d;
    public final f e;
    public final int f;

    /* compiled from: MonthsPagerAdapter */
    public static class a extends z {
        public final TextView t;
        public final MaterialCalendarGridView u;

        public a(LinearLayout linearLayout, boolean z) {
            super(linearLayout);
            TextView textView = (TextView) linearLayout.findViewById(2131296725);
            this.t = textView;
            WeakHashMap weakHashMap = b.i.k.o.a;
            r rVar = new r(2131297019, Boolean.class, 28);
            Boolean bool = Boolean.TRUE;
            if ((VERSION.SDK_INT >= 28 ? 1 : null) != null) {
                rVar.d(textView, bool);
            } else if (rVar.e(rVar.c(textView), bool)) {
                b.i.k.a f = b.i.k.o.f(textView);
                if (f == null) {
                    f = new b.i.k.a();
                }
                b.i.k.o.p(textView, f);
                textView.setTag(rVar.a, bool);
                b.i.k.o.i(textView, 0);
            }
            this.u = (MaterialCalendarGridView) linearLayout.findViewById(2131296720);
            if (!z) {
                textView.setVisibility(8);
            }
        }
    }

    public o(Context context, DateSelector<?> dateSelector, CalendarConstraints calendarConstraints, f fVar) {
        Month month = calendarConstraints.a;
        Month month2 = calendarConstraints.b;
        Month month3 = calendarConstraints.c;
        if (month.compareTo(month3) > 0) {
            throw new IllegalArgumentException("firstPage cannot be after currentPage");
        } else if (month3.compareTo(month2) <= 0) {
            int i = m.e;
            int i2 = d.i0;
            this.f = (i * context.getResources().getDimensionPixelSize(2131165386)) + (l.q0(context) ? context.getResources().getDimensionPixelSize(2131165386) : 0);
            this.c = calendarConstraints;
            this.d = dateSelector;
            this.e = fVar;
            if (this.a.a()) {
                throw new IllegalStateException("Cannot change whether this adapter has stable IDs while the adapter has registered observers.");
            }
            this.b = true;
        } else {
            throw new IllegalArgumentException("currentPage cannot be after lastPage");
        }
    }

    public int a() {
        return this.c.f;
    }

    public long b(int i) {
        return this.c.a.c(i).a.getTimeInMillis();
    }

    public void f(z zVar, int i) {
        a aVar = (a) zVar;
        Month c = this.c.a.c(i);
        aVar.t.setText(c.b);
        MaterialCalendarGridView materialCalendarGridView = (MaterialCalendarGridView) aVar.u.findViewById(2131296720);
        if (materialCalendarGridView.getAdapter() == null || !c.equals(materialCalendarGridView.getAdapter().a)) {
            ListAdapter mVar = new m(c, this.d, this.c);
            materialCalendarGridView.setNumColumns(c.e);
            materialCalendarGridView.setAdapter(mVar);
        } else {
            materialCalendarGridView.getAdapter().notifyDataSetChanged();
        }
        materialCalendarGridView.setOnItemClickListener(new n(this, materialCalendarGridView));
    }

    public z g(ViewGroup viewGroup, int i) {
        LinearLayout linearLayout = (LinearLayout) LayoutInflater.from(viewGroup.getContext()).inflate(2131493014, viewGroup, false);
        if (!l.q0(viewGroup.getContext())) {
            return new a(linearLayout, false);
        }
        linearLayout.setLayoutParams(new LayoutParams(-1, this.f));
        return new a(linearLayout, true);
    }

    public Month h(int i) {
        return this.c.a.c(i);
    }

    public int i(Month month) {
        return this.c.a.d(month);
    }
}
